import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

public class Main {

	/*以空格为分隔符，将line转换为List<String>*/
	public static List<String> convertStringToList(String line){
		Scanner sc=new Scanner(line);
		while(sc.hasNext()){
			sc.next();
		}
	   List<String> words=new ArrayList<String>();
	   while(sc.hasNext()){
		   words.add(sc.next());
	   }
		sc.close();
		return words;
		
	}
	/*在list中移除掉以与str内容相同的元素*/
	public static void remove(List<String> list, String str){ 
		Iterator<String> integerList = list.iterator();
		while(integerList.hasNext()){
			if(integerList.next().equals(str))
				integerList.remove();
		}
				
			
		}
		
	

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            List<String> list = convertStringToList(sc.nextLine());
            System.out.println(list);
            String word = sc.nextLine();
            remove(list,word);
            System.out.println(list);
        }
        sc.close();
    }

}